<!-- HTML header for doxygen 1.8.10-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.3"/>
<title>NATS C Client with JetStream and Streaming support: Subscribing</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="customdoxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;" >
   <div id="projectname">NATS C Client with JetStream and Streaming support
   &#160;<span id="projectnumber">3.3.0</span>
   </div>
   <div id="projectbrief">The nats.io C Client, Supported by Synadia Communications Inc.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.3 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('group__js_sub_group.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">Subscribing<div class="ingroups"><a class="el" href="group__func_group.html">Functions</a> &raquo; <a class="el" href="group__js_group.html">JetStream</a></div></div></div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga472adb949d1af9d8f07bda99f5d7f3f8"><td class="memItemLeft" align="right" valign="top"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__js_sub_group.html#ga472adb949d1af9d8f07bda99f5d7f3f8">jsSubOptions_Init</a> (<a class="el" href="structjs_sub_options.html">jsSubOptions</a> *opts)</td></tr>
<tr class="memdesc:ga472adb949d1af9d8f07bda99f5d7f3f8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes a subscribe options structure.  <a href="group__js_sub_group.html#ga472adb949d1af9d8f07bda99f5d7f3f8">More...</a><br /></td></tr>
<tr class="separator:ga472adb949d1af9d8f07bda99f5d7f3f8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa686c6efd84ef963de1925108e896515"><td class="memItemLeft" align="right" valign="top"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__js_sub_group.html#gaa686c6efd84ef963de1925108e896515">js_Subscribe</a> (<a class="el" href="group__types_group.html#ga87158ec63b4f90f69e20451624ea01d8">natsSubscription</a> **sub, <a class="el" href="group__types_group.html#gaaf12cdd24c6cc23a57c20466c92ff8c1">jsCtx</a> *js, const char *subject, <a class="el" href="group__callbacks_group.html#gad1a5ac566893e13dc8c81ac0e9c87afe">natsMsgHandler</a> cb, void *cbClosure, <a class="el" href="structjs_options.html">jsOptions</a> *opts, <a class="el" href="structjs_sub_options.html">jsSubOptions</a> *subOpts, <a class="el" href="status_8h.html#a10731415ffcd3e2330df10c4d5fd3d70">jsErrCode</a> *errCode)</td></tr>
<tr class="memdesc:gaa686c6efd84ef963de1925108e896515"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create an asynchronous subscription.  <a href="group__js_sub_group.html#gaa686c6efd84ef963de1925108e896515">More...</a><br /></td></tr>
<tr class="separator:gaa686c6efd84ef963de1925108e896515"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gabacb010031e535f9fb6e2167337e8adf"><td class="memItemLeft" align="right" valign="top"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__js_sub_group.html#gabacb010031e535f9fb6e2167337e8adf">js_SubscribeSync</a> (<a class="el" href="group__types_group.html#ga87158ec63b4f90f69e20451624ea01d8">natsSubscription</a> **sub, <a class="el" href="group__types_group.html#gaaf12cdd24c6cc23a57c20466c92ff8c1">jsCtx</a> *js, const char *subject, <a class="el" href="structjs_options.html">jsOptions</a> *opts, <a class="el" href="structjs_sub_options.html">jsSubOptions</a> *subOpts, <a class="el" href="status_8h.html#a10731415ffcd3e2330df10c4d5fd3d70">jsErrCode</a> *errCode)</td></tr>
<tr class="memdesc:gabacb010031e535f9fb6e2167337e8adf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create a synchronous subscription.  <a href="group__js_sub_group.html#gabacb010031e535f9fb6e2167337e8adf">More...</a><br /></td></tr>
<tr class="separator:gabacb010031e535f9fb6e2167337e8adf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaaeaddb73857aa4eb4901eec945ed27cd"><td class="memItemLeft" align="right" valign="top"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__js_sub_group.html#gaaeaddb73857aa4eb4901eec945ed27cd">js_PullSubscribe</a> (<a class="el" href="group__types_group.html#ga87158ec63b4f90f69e20451624ea01d8">natsSubscription</a> **sub, <a class="el" href="group__types_group.html#gaaf12cdd24c6cc23a57c20466c92ff8c1">jsCtx</a> *js, const char *subject, const char *durable, <a class="el" href="structjs_options.html">jsOptions</a> *opts, <a class="el" href="structjs_sub_options.html">jsSubOptions</a> *subOpts, <a class="el" href="status_8h.html#a10731415ffcd3e2330df10c4d5fd3d70">jsErrCode</a> *errCode)</td></tr>
<tr class="memdesc:gaaeaddb73857aa4eb4901eec945ed27cd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create a pull subscriber.  <a href="group__js_sub_group.html#gaaeaddb73857aa4eb4901eec945ed27cd">More...</a><br /></td></tr>
<tr class="separator:gaaeaddb73857aa4eb4901eec945ed27cd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafc5e0d2269bd23b4d5fb7f3b05278e50"><td class="memItemLeft" align="right" valign="top"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__js_sub_group.html#gafc5e0d2269bd23b4d5fb7f3b05278e50">natsSubscription_Fetch</a> (<a class="el" href="structnats_msg_list.html">natsMsgList</a> *list, <a class="el" href="group__types_group.html#ga87158ec63b4f90f69e20451624ea01d8">natsSubscription</a> *sub, int batch, int64_t timeout, <a class="el" href="status_8h.html#a10731415ffcd3e2330df10c4d5fd3d70">jsErrCode</a> *errCode)</td></tr>
<tr class="memdesc:gafc5e0d2269bd23b4d5fb7f3b05278e50"><td class="mdescLeft">&#160;</td><td class="mdescRight">Fetches messages for a pull subscription.  <a href="group__js_sub_group.html#gafc5e0d2269bd23b4d5fb7f3b05278e50">More...</a><br /></td></tr>
<tr class="separator:gafc5e0d2269bd23b4d5fb7f3b05278e50"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaae716a1431db065744c079b71a9f4c2e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__js_sub_group.html#gaae716a1431db065744c079b71a9f4c2e">natsSubscription_GetConsumerInfo</a> (<a class="el" href="structjs_consumer_info.html">jsConsumerInfo</a> **ci, <a class="el" href="group__types_group.html#ga87158ec63b4f90f69e20451624ea01d8">natsSubscription</a> *sub, <a class="el" href="structjs_options.html">jsOptions</a> *opts, <a class="el" href="status_8h.html#a10731415ffcd3e2330df10c4d5fd3d70">jsErrCode</a> *errCode)</td></tr>
<tr class="memdesc:gaae716a1431db065744c079b71a9f4c2e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the <a class="el" href="structjs_consumer_info.html">jsConsumerInfo</a> associated with this subscription.  <a href="group__js_sub_group.html#gaae716a1431db065744c079b71a9f4c2e">More...</a><br /></td></tr>
<tr class="separator:gaae716a1431db065744c079b71a9f4c2e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0daed9f0d2d00cb14314ecc180a6fa84"><td class="memItemLeft" align="right" valign="top"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__js_sub_group.html#ga0daed9f0d2d00cb14314ecc180a6fa84">natsSubscription_GetSequenceMismatch</a> (<a class="el" href="structjs_consumer_sequence_mismatch.html">jsConsumerSequenceMismatch</a> *csm, <a class="el" href="group__types_group.html#ga87158ec63b4f90f69e20451624ea01d8">natsSubscription</a> *sub)</td></tr>
<tr class="memdesc:ga0daed9f0d2d00cb14314ecc180a6fa84"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the consumer sequence mismatch information.  <a href="group__js_sub_group.html#ga0daed9f0d2d00cb14314ecc180a6fa84">More...</a><br /></td></tr>
<tr class="separator:ga0daed9f0d2d00cb14314ecc180a6fa84"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p >Subscribing functions </p>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga472adb949d1af9d8f07bda99f5d7f3f8" name="ga472adb949d1af9d8f07bda99f5d7f3f8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga472adb949d1af9d8f07bda99f5d7f3f8">&#9670;&nbsp;</a></span>jsSubOptions_Init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> jsSubOptions_Init </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structjs_sub_options.html">jsSubOptions</a> *&#160;</td>
          <td class="paramname"><em>opts</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p >Use this before setting specific subscribe options and passing this configuration to the JetStream subscribe APIs.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">opts</td><td>the pointer to the <a class="el" href="structjs_sub_options.html">jsSubOptions</a> to initialize. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gaa686c6efd84ef963de1925108e896515" name="gaa686c6efd84ef963de1925108e896515"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa686c6efd84ef963de1925108e896515">&#9670;&nbsp;</a></span>js_Subscribe()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> js_Subscribe </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__types_group.html#ga87158ec63b4f90f69e20451624ea01d8">natsSubscription</a> **&#160;</td>
          <td class="paramname"><em>sub</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types_group.html#gaaf12cdd24c6cc23a57c20466c92ff8c1">jsCtx</a> *&#160;</td>
          <td class="paramname"><em>js</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>subject</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__callbacks_group.html#gad1a5ac566893e13dc8c81ac0e9c87afe">natsMsgHandler</a>&#160;</td>
          <td class="paramname"><em>cb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>cbClosure</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structjs_options.html">jsOptions</a> *&#160;</td>
          <td class="paramname"><em>opts</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structjs_sub_options.html">jsSubOptions</a> *&#160;</td>
          <td class="paramname"><em>subOpts</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="status_8h.html#a10731415ffcd3e2330df10c4d5fd3d70">jsErrCode</a> *&#160;</td>
          <td class="paramname"><em>errCode</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sub</td><td>the location where to store the pointer to the newly created <a class="el" href="group__types_group.html#ga87158ec63b4f90f69e20451624ea01d8" title="Interest on a given subject.">natsSubscription</a> object. </td></tr>
    <tr><td class="paramname">js</td><td>the pointer to the <a class="el" href="group__types_group.html#gaaf12cdd24c6cc23a57c20466c92ff8c1">jsCtx</a> object. </td></tr>
    <tr><td class="paramname">subject</td><td>the subject this subscription is created for. </td></tr>
    <tr><td class="paramname">cb</td><td>the <a class="el" href="group__callbacks_group.html#gad1a5ac566893e13dc8c81ac0e9c87afe" title="Callback used to deliver messages to the application.">natsMsgHandler</a> callback. </td></tr>
    <tr><td class="paramname">cbClosure</td><td>a pointer to an user defined object (can be <code>NULL</code>). See the <a class="el" href="group__callbacks_group.html#gad1a5ac566893e13dc8c81ac0e9c87afe" title="Callback used to deliver messages to the application.">natsMsgHandler</a> prototype. </td></tr>
    <tr><td class="paramname">opts</td><td>the pointer to the <a class="el" href="structjs_options.html">jsOptions</a> object, possibly <code>NULL</code>. </td></tr>
    <tr><td class="paramname">subOpts</td><td>the subscribe options, possibly <code>NULL</code>. </td></tr>
    <tr><td class="paramname">errCode</td><td>the location where to store the JetStream specific error code, or <code>NULL</code> if not needed. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gabacb010031e535f9fb6e2167337e8adf" name="gabacb010031e535f9fb6e2167337e8adf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gabacb010031e535f9fb6e2167337e8adf">&#9670;&nbsp;</a></span>js_SubscribeSync()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> js_SubscribeSync </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__types_group.html#ga87158ec63b4f90f69e20451624ea01d8">natsSubscription</a> **&#160;</td>
          <td class="paramname"><em>sub</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types_group.html#gaaf12cdd24c6cc23a57c20466c92ff8c1">jsCtx</a> *&#160;</td>
          <td class="paramname"><em>js</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>subject</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structjs_options.html">jsOptions</a> *&#160;</td>
          <td class="paramname"><em>opts</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structjs_sub_options.html">jsSubOptions</a> *&#160;</td>
          <td class="paramname"><em>subOpts</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="status_8h.html#a10731415ffcd3e2330df10c4d5fd3d70">jsErrCode</a> *&#160;</td>
          <td class="paramname"><em>errCode</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sub</td><td>the location where to store the pointer to the newly created <a class="el" href="group__types_group.html#ga87158ec63b4f90f69e20451624ea01d8" title="Interest on a given subject.">natsSubscription</a> object. </td></tr>
    <tr><td class="paramname">js</td><td>the pointer to the <a class="el" href="group__types_group.html#gaaf12cdd24c6cc23a57c20466c92ff8c1">jsCtx</a> object. </td></tr>
    <tr><td class="paramname">subject</td><td>the subject this subscription is created for. the <a class="el" href="group__callbacks_group.html#gad1a5ac566893e13dc8c81ac0e9c87afe" title="Callback used to deliver messages to the application.">natsMsgHandler</a> prototype. </td></tr>
    <tr><td class="paramname">opts</td><td>the pointer to the <a class="el" href="structjs_options.html">jsOptions</a> object, possibly <code>NULL</code>. </td></tr>
    <tr><td class="paramname">subOpts</td><td>the subscribe options, possibly <code>NULL</code>. </td></tr>
    <tr><td class="paramname">errCode</td><td>the location where to store the JetStream specific error code, or <code>NULL</code> if not needed. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gaaeaddb73857aa4eb4901eec945ed27cd" name="gaaeaddb73857aa4eb4901eec945ed27cd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaaeaddb73857aa4eb4901eec945ed27cd">&#9670;&nbsp;</a></span>js_PullSubscribe()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> js_PullSubscribe </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__types_group.html#ga87158ec63b4f90f69e20451624ea01d8">natsSubscription</a> **&#160;</td>
          <td class="paramname"><em>sub</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types_group.html#gaaf12cdd24c6cc23a57c20466c92ff8c1">jsCtx</a> *&#160;</td>
          <td class="paramname"><em>js</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>subject</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>durable</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structjs_options.html">jsOptions</a> *&#160;</td>
          <td class="paramname"><em>opts</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structjs_sub_options.html">jsSubOptions</a> *&#160;</td>
          <td class="paramname"><em>subOpts</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="status_8h.html#a10731415ffcd3e2330df10c4d5fd3d70">jsErrCode</a> *&#160;</td>
          <td class="paramname"><em>errCode</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p >A pull based consumer is a type of consumer that does not have a delivery subject, that is the library has to request for the messages to be delivered as needed from the server.</p>
<dl class="section note"><dt>Note</dt><dd>All pull subscriptions must have a durable name.</dd>
<dd>
A durable name cannot contain the character ".".</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sub</td><td>the location where to store the pointer to the newly created <a class="el" href="group__types_group.html#ga87158ec63b4f90f69e20451624ea01d8" title="Interest on a given subject.">natsSubscription</a> object. </td></tr>
    <tr><td class="paramname">js</td><td>the pointer to the <a class="el" href="group__types_group.html#gaaf12cdd24c6cc23a57c20466c92ff8c1">jsCtx</a> object. </td></tr>
    <tr><td class="paramname">subject</td><td>the subject this subscription is created for. </td></tr>
    <tr><td class="paramname">durable</td><td>the durable name, which is required for pull subscriptions. </td></tr>
    <tr><td class="paramname">opts</td><td>the pointer to the <a class="el" href="structjs_options.html">jsOptions</a> object, possibly <code>NULL</code>. </td></tr>
    <tr><td class="paramname">subOpts</td><td>the subscribe options, possibly <code>NULL</code>. </td></tr>
    <tr><td class="paramname">errCode</td><td>the location where to store the JetStream specific error code, or <code>NULL</code> if not needed. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gafc5e0d2269bd23b4d5fb7f3b05278e50" name="gafc5e0d2269bd23b4d5fb7f3b05278e50"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gafc5e0d2269bd23b4d5fb7f3b05278e50">&#9670;&nbsp;</a></span>natsSubscription_Fetch()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> natsSubscription_Fetch </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structnats_msg_list.html">natsMsgList</a> *&#160;</td>
          <td class="paramname"><em>list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types_group.html#ga87158ec63b4f90f69e20451624ea01d8">natsSubscription</a> *&#160;</td>
          <td class="paramname"><em>sub</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>batch</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int64_t&#160;</td>
          <td class="paramname"><em>timeout</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="status_8h.html#a10731415ffcd3e2330df10c4d5fd3d70">jsErrCode</a> *&#160;</td>
          <td class="paramname"><em>errCode</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p >Fetches up to <code>batch</code> messages from the server, waiting up to <code>timeout</code> milliseconds. No more thant <code>batch</code> messages will be returned, however, it can be less.</p>
<p >For <code>batch</code> greater than <code>1</code>, this call will not necessarily wait up <code>timeout</code> milliseconds if some messages were collected and the library receives a notification that no more messages are available at this time.<br  />
 It means that calling <code>natsSubscription_Fetch(&amp;list, sub, 10, 5000)</code> may return after less than 5 seconds with only 3 messages.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>the location to a <a class="el" href="structnats_msg_list.html" title="A list of NATS messages.">natsMsgList</a> that will be filled by the result of this call. </td></tr>
    <tr><td class="paramname">sub</td><td>the pointer to the <a class="el" href="group__types_group.html#ga87158ec63b4f90f69e20451624ea01d8" title="Interest on a given subject.">natsSubscription</a> object. </td></tr>
    <tr><td class="paramname">batch</td><td>the batch size, that is, the maximum number of messages to return. </td></tr>
    <tr><td class="paramname">timeout</td><td>the timeout (required) expressed in number of milliseconds. </td></tr>
    <tr><td class="paramname">errCode</td><td>the location where to store the JetStream specific error code, or <code>NULL</code> if not needed. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gaae716a1431db065744c079b71a9f4c2e" name="gaae716a1431db065744c079b71a9f4c2e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaae716a1431db065744c079b71a9f4c2e">&#9670;&nbsp;</a></span>natsSubscription_GetConsumerInfo()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> natsSubscription_GetConsumerInfo </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structjs_consumer_info.html">jsConsumerInfo</a> **&#160;</td>
          <td class="paramname"><em>ci</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types_group.html#ga87158ec63b4f90f69e20451624ea01d8">natsSubscription</a> *&#160;</td>
          <td class="paramname"><em>sub</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structjs_options.html">jsOptions</a> *&#160;</td>
          <td class="paramname"><em>opts</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="status_8h.html#a10731415ffcd3e2330df10c4d5fd3d70">jsErrCode</a> *&#160;</td>
          <td class="paramname"><em>errCode</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p >Returns the <a class="el" href="structjs_consumer_info.html">jsConsumerInfo</a> associated with this subscription.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ci</td><td>the location where to store the pointer to the new <a class="el" href="structjs_consumer_info.html">jsConsumerInfo</a> object. </td></tr>
    <tr><td class="paramname">sub</td><td>the pointer to the <a class="el" href="group__types_group.html#ga87158ec63b4f90f69e20451624ea01d8" title="Interest on a given subject.">natsSubscription</a> object. </td></tr>
    <tr><td class="paramname">opts</td><td>the pointer to the <a class="el" href="structjs_options.html">jsOptions</a> object, possibly <code>NULL</code>. </td></tr>
    <tr><td class="paramname">errCode</td><td>the location where to store the JetStream specific error code, or <code>NULL</code> if not needed. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga0daed9f0d2d00cb14314ecc180a6fa84" name="ga0daed9f0d2d00cb14314ecc180a6fa84"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga0daed9f0d2d00cb14314ecc180a6fa84">&#9670;&nbsp;</a></span>natsSubscription_GetSequenceMismatch()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> natsSubscription_GetSequenceMismatch </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structjs_consumer_sequence_mismatch.html">jsConsumerSequenceMismatch</a> *&#160;</td>
          <td class="paramname"><em>csm</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types_group.html#ga87158ec63b4f90f69e20451624ea01d8">natsSubscription</a> *&#160;</td>
          <td class="paramname"><em>sub</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p >If <code>Heartbeat</code> is configured in <a class="el" href="structjs_consumer_config.html">jsConsumerConfig</a> object (or configured in an existing JetStream consumer), the server sends heartbeats to the client at the given interval.</p>
<p >Those heartbeats contains information that allow the application to detect a mismatch between the server and client's view of the state of the consumer.</p>
<p >If the library detects a sequence mismatch, the behavior is different depending on the type of subscription:</p>
<ul>
<li>For asynchronous subscriptions: the error <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80a22fa4802a34bac497f23e269a20a52f2" title="For JetStream subscriptions, it means that a consumer sequence mismatch was discovered.">NATS_MISMATCH</a> is published to the error handler (see <a class="el" href="group__opts_group.html#ga127ec7a8196b453947a7fa9a64096cbd" title="Sets the error handler for asynchronous events.">natsOptions_SetErrorHandler</a>).</li>
<li>For synchronous subscriptions: the next call to <a class="el" href="group__sub_group.html#ga6538a5d78dfb0f16514b94c8e74c11af" title="Returns the next available message.">natsSubscription_NextMsg()</a> will return the error <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80a22fa4802a34bac497f23e269a20a52f2" title="For JetStream subscriptions, it means that a consumer sequence mismatch was discovered.">NATS_MISMATCH</a> (but will succeed afterwards).</li>
</ul>
<p >In both cases, the user should check what the mismatch is using this function and possibly recreate the consumer based on the provided information.</p>
<dl class="section note"><dt>Note</dt><dd>For a valid JetStream subscription, this function will return <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80ad0229a12b17d3d12a28efed6213720d8">NATS_NOT_FOUND</a> if no consumer sequence mismatch has been detected.</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="structjs_consumer_sequence_mismatch.html">jsConsumerSequenceMismatch</a></dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">csm</td><td>the pointer location where to copy the consumer sequence mismatch information. </td></tr>
    <tr><td class="paramname">sub</td><td>the pointer to the <a class="el" href="group__types_group.html#ga87158ec63b4f90f69e20451624ea01d8" title="Interest on a given subject.">natsSubscription</a> object. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.10-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">NATS.IO Supported By Synadia Communications Inc.
    <a href="http://www.nats.io">
    </a></li>
  </ul>
</div>
</body>
</html>
